#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

struct w
{
    int d,v,a;
    long long x;
}che[N];

int mm[N];

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    //freopen("BF.out","w",stdin);
    int t;
    scanf("%d",&t);
    while(t --)
    {
        //memset(mm,0,sizeof mm);
        bool b1 = true,b2 = true,b3 = true;
        int n,m,l,v;
        scanf("%d%d%d%d",&n,&m,&l,&v);
        for(int i = 1;i <= n;i ++)
        {
            scanf("%d%d%d",&che[i].d,&che[i].v,&che[i].a);
            if(che[i].a != 0)
                b1 = false;
            if(che[i].a < 0)
                b2 = false;
            if(che[i].a > 0)
                b3 = false;
            if(che[i].v <= v && che[i].a <= 0)
            {
                che[i].x = l + 1;
                continue;
            }
            if(che[i].v > v && che[i].a >= 0)
            {
                che[i].x = che[i].d;
                continue;
            }
            long long vv = (long long)v * v - (long long)che[i].v * che[i].v;
            long long aa = (long long)2 * che[i].a;
            che[i].x = abs(vv)/abs(aa);
            if(vv % aa == 0 && aa < 0)
                che[i].x --;
            if(aa > 0)
                che[i].x ++;
            che[i].x += che[i].d;
            //cout << "i = " << i << " che[i].x = " << che[i].x << endl;
        }
        for(int i = 1;i <= m;i ++)
            scanf("%d",&mm[i]);
        mm[m + 1] = l + 1;
        int ans1 = 0;
        for(int i = 1;i <= n;i ++)
        {
            if(che[i].a >= 0)
            {
                if(che[i].x > l) continue;
                int num = lower_bound(mm + 1,mm + m + 1,che[i].x) - mm;
                //cout << "i = " << i << " num = " << num << endl;
                if(num <= m)
                    ans1 ++;
            }
            else if(che[i].v > v)
            {
                int num1 = lower_bound(mm + 1,mm + m + 1,che[i].d) - mm;
                if(che[i].x > l && num1 <= m)
                {
                    ans1 ++;
                    continue;
                }
                int num = upper_bound(mm + 1,mm + m + 1,che[i].x) - mm;
                //cout << "i = " << i << " num = " << num << " num1 = " << num1 << endl;
                if(num1 <= m && num > num1)
                        ans1 ++;
            }
            //cout << "ans = " << ans1 << endl;
        }
        cout << ans1 << ' ';
        if(b1 || b2)
        {
            if(ans1 != 0)
            cout << m - 1 << endl;
            else
                cout << m << endl;
        }
        else if(n <= 20 && m <= 20)
        {
            int ans2 = 0;
            for(int s = 1;s < (1 << m);s ++)
            {
                bool u = true;
                for(int i = 1;i <= n;i ++)
                {
                    if(che[i].a >= 0)
                    {
                        if(che[i].x > l) continue;
                        int num = lower_bound(mm + 1,mm + m + 1,che[i].x) - mm;
                        //cout << "i = " << i << " num = " << num << endl;
                        if(s >> (num - 1) <= 0)
                        {
                            u = false;
                            break;
                        }
                    }
                    else if(che[i].v > v)
                    {
                        int num1 = lower_bound(mm + 1,mm + m + 1,che[i].d) - mm;
                        if(che[i].x > l && num1 <= m)
                        {
                            if(s >> (num1 - 1) <= 0)
                            {
                                u = false;
                                break;
                            }
                        }
                        int num = upper_bound(mm + 1,mm + m + 1,che[i].x) - mm;
                        //cout << "i = " << i << " num = " << num << " num1 = " << num1 << endl;
                        if(num1 <= m && num > num1)
                            if(s >> (num1 - 1) <= 0 || (s >> (num1 - 1)) - ((s >> (num - 1)) << (num - num1)) <= 0)
                            {
                                u = false;
                                break;
                            }
                    }
                }
                if(u == true)
                {
                    int o = 0;
                    for(int i = 0;i < m;i ++)
                        if((s >> i) & 1)
                        o ++;
                    ans2 = max(ans2,m - o);
                    //cout << s << ' ' << ans2 << endl;
                }
            }
            cout << ans2 << endl;
        }


    }
    return 0;
}
